﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WSBackup
{
    static class Extensions
    {
        /// <summary>
        /// Get substring of specified number of characters on the right.
        /// </summary>
        public static string Right(this string value, int length)
        {
            if (value.Length < length)
                return value;
            return value.Substring(value.Length - length);
        }

        /// <summary>
        /// Get substring of specified number of characters on the left.
        /// </summary>
        public static string Left(this string value, int length)
        {
            if (length < 0)
                length = value.Length + length;

            if (length > value.Length)
                return value;
            return value.Substring(0, length);
        }
    }
}
